package com.egao.common.system.biz.impl;

import com.egao.common.core.damon.results.BaseDao;
import com.egao.common.system.biz.RoleBiz;
import com.egao.common.system.entity.Role;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 * 数据层实现类
 * @author : Doman
 * @date : 2020-05-27 15:04:13
 * @version ：1.0
 */
@Repository
public class RoleBizImpl extends BaseDao implements RoleBiz {

	@Override
	public List<Role> list(Role role) {
		Map<String, String> map  = new HashMap<String, String>();
		RowMapper<Role> rm = new BeanPropertyRowMapper<Role>(Role.class);
		StringBuffer sql = new StringBuffer("select r.* ");
		sql.append(" from sys_role r ");
		sql.append(" inner join sys_user_role ur on ur.role_id=r.role_id ");
		sql.append(" where r.deleted=0 and ur.user_id=:user_id");
		map.put("user_id", role.getUserId()+"");

		getMapParameter(sql, map);
		return jdbcTemplate.query(sql.toString(),map, rm);
	}
}
